<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8" isELIgnored="false"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
	<head>
		<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
		<meta http-equiv="X-UA-Compatible" content="IE=edge">
		<meta name="viewport" content="width=device-width, initial-scale=1">
		<title>众筹管理后台</title>
		<link rel="stylesheet" href="admin/css/bootstrap.min.css" />
		<link rel="stylesheet" href="admin/css/dashboard.css" />
	</head>
	<body>
		<nav class="navbar navbar-inverse navbar-fixed-top">
			<div class="container-fluid">
				<div class="navbar-header">
					<button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#navbar" aria-expanded="false"
					 aria-controls="navbar">
						<span class="sr-only">Toggle navigation</span>
						<span class="icon-bar"></span>
						<span class="icon-bar"></span>
						<span class="icon-bar"></span>
					</button>
					<a class="navbar-brand" href="#">众筹管理平台</a>
				</div>
				<div id="navbar" class="navbar-collapse collapse">
					<ul class="nav navbar-nav navbar-right">
						<li><a href="index.html">首页</a></li>
						<li><a href="#">欢迎, ${sessionScope.admin.adminName}</a></li>
						<!-- <li><a href="#" title="修改个人资料和密码的页面">设置</a></li> -->
						<li><a href="logout" title="退出登录">退出</a></li>
					</ul>
				</div>
			</div>
		</nav>
		<div class="container-fluid">
			<div class="row">
				<div class="col-sm-3 col-md-2 sidebar">
					<ul class="nav nav-sidebar">
						<li><a href="toBackstageIndex">首页</a></li>
					</ul>
					<ul id="products" class="nav nav-sidebar">
						<li class="active"><a href="#suo_you_xiang_mu" data-toggle="tab">所有项目</a></li>
						<li><a href="#xiangMuShenHe" data-toggle="tab">项目审核</a></li>
						<li><a href="#xiangMuPingLun" data-toggle="tab">项目评论</a></li>
						<li><a href="#xiangMuFenLei" data-toggle="tab">项目分类</a></li>
						<li><a href="#xiangMuTuiJian" data-toggle="tab">项目推荐</a></li>
					</ul>
					<ul class="nav nav-sidebar">
						<li><a href="toBackManages">用户管理</a></li>
						<li><a href="toBackManages">用户资金</a></li>
						<li><a href="toBackManages">实名审核</a></li>
						<li><a href="toBackManages">新闻管理</a></li>
						<li><a href="toBackManages">添加新闻</a></li>
					</ul>
					<ul class="nav nav-sidebar">
						
						<!-- <li><a href="">问题管理</a></li>
						<li><a href="${pageContext.request.contextPath}/back/user/list.action">管理用户</a></li>
						<li><a href="">管理日志</a></li> -->
					</ul>
				</div>

				<div id="products1" class="tab-content col-sm-9 col-sm-offset-3 col-md-10 col-md-offset-2 main">
					<div id="chaxunxianshi">
						<h1 id="suoyouh1" class="page-header">所有众筹项目</h1>
						<div id="suoyoutiaojian" class="panel panel-default">
							<div class="panel-body">
								<form class="form-inline">
									<div class="form-group">
										<input type="text" class="form-control" id="exampleInputName22" placeholder="项目名称">
									</div>
									<div class="form-group">
										<input type="text" class="form-control" id="exampleInputName23" placeholder="项目发起人">
									</div>
									<div class="form-group" >
										<select class=form-control id="exampleInputName24">
											<option value="">项目状态</option>
											<option value="2">众筹中</option>
											<option value="3">众筹失败</option>
											<option value="4">众筹成功</option>
										</select>
									</div>
									<div class="form-group" >
										<select class=form-control id="exampleInputName25">
											<option value="">项目类型</option>
											<option value="1">教育助学</option>
											<option value="2">爱心环保</option>
											<option value="3">扶贫助困</option>
											<option value="4">公益创业</option>
											<option value="5">公益活动</option>
										</select>
									</div>
									&nbsp;&nbsp;
									<button type="button" class="btn btn-default btn-primary" onclick="tiaojianchapro1(1)">查询</button>
								</form>
							</div>
						</div>
					</div>

					<div id="suo_you_xiang_mu" class="panel panel-default tab-pane active">
						<div class="panel-heading">
							<div class="panel-title">
								所项目列表
							</div>
						</div>
						<div class="panel-body">
							<div class="table-responsive ">
								<table class="table table-striped table-bordered">
									<thead>
										<tr>
											<th>序号</th>
											<th>项目类型</th>
											<th>项目名称</th>
											<!-- <th>项目进度</th> -->
											<th>开始日期</th>
											<th>结束日期</th>
											<th>已筹金额</th>
											<th>发起人</th>
											<th>操作</th>
										</tr>
									</thead>
									<tbody id="projectslist">
									</tbody>
								</table>
							</div>
							<nav aria-label="Page navigation" class="text-right">
								<ul class="pagination" id="showPage">
								</ul>
							</nav>
						</div>
					</div>
					<div id="xiangMuShenHe" class="panel panel-default tab-pane">
						<div class="modal fade" id="myModal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel">
							<div class="modal-dialog" role="document">
								<div class="modal-content">
									<div class="modal-header">
										<button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>
										<h4 class="modal-title" id="myModalLabel">通过审核</h4>
									</div>
									<div class="modal-body">
										你确定要通过该项目的审核吗？
									</div>
									<div class="modal-footer">
										<button type="button" class="btn btn-default" data-dismiss="modal">Close</button>
										<button id="btu_Yes" type="button" psID="" class="btn btn-primary">通过</button>
									</div>
								</div>
							</div>
						</div>
						<div class="modal fade" id="myModal1" tabindex="-1" role="dialog" aria-labelledby="myModalLabel">
							<div class="modal-dialog" role="document">
								<div class="modal-content">
									<div class="modal-header">
										<button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>
										<h4 class="modal-title" id="myModalLabel">审核不通过</h4>
									</div>
									<div class="modal-body">
										你确定要禁止通过该项目吗？
									</div>
									<div class="modal-footer">
										<button type="button" class="btn btn-default" data-dismiss="modal">Close</button>
										<button id="btu_No" type="button" psID="" class="btn btn-warning">禁止</button>
									</div>
								</div>
							</div>
						</div>
						<div class="panel-heading">
							<div class="panel-title">
								待审核项目列表
							</div>
						</div>
						<div class="panel-body">
							<div class="table-responsive ">
								<table class="table table-striped table-bordered">
									<thead>
										<tr>
											<th>序号</th>
											<th>项目类型</th>
											<th>项目名称</th>
											<!-- <th>项目进度</th> -->
											<th>筹资金额</th>
											<th>筹款目的</th>
											<th>筹资天数</th>
											<th>发起人</th>
											<th>操作</th>
										</tr>
									</thead>
									<tbody id="xiangmushenhe_msg">
									</tbody>
								</table>
							</div>
							<nav aria-label="Page navigation" class="text-right">
								<ul class="pagination" id="showPage_shenhe">
								</ul>
							</nav>
						</div>
					</div>

					<div id="xiangMuPingLun" class="panel panel-default tab-pane">
						<div class="panel-heading">
							<div class="panel-title">
								项目评论列表
							</div>
						</div>
						<div class="panel-body">
							<div class="table-responsive ">
								<table class="table table-striped table-bordered">
									<thead>
										<tr>
											<th>评论内容</th>
											<th>评论人</th>
											<th>评论时间</th>
											<th>操作</th>
										</tr>
									</thead>
									<tbody id="xiangMuPingLun_msg">
									</tbody>
								</table>
							</div>
							<nav aria-label="Page navigation" class="text-right">
								<ul class="pagination" id="showPage_xiangMuPingLun1">
								</ul>
							</nav>
							
						</div>
					</div>
					<div id="xiangMuFenLei" class="panel panel-default tab-pane">
						<!-- Modal -->
						<div class="modal fade" id="myModal5" tabindex="-1" role="dialog" aria-labelledby="myModalLabel">
						  <div class="modal-dialog" role="document">
						    <div class="modal-content">
						      <div class="modal-header">
						        <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>
						        <h4 class="modal-title" id="myModalLabel">添加公益类型</h4>
						      </div>
						      <div class="modal-body">
								  <form>
								    <div class="form-group">
								      <label for="exampleInputEmail1">公益类型名字</label>
								      <input type="text" class="form-control" id="gName" placeholder="公益类型名字">
								    </div>
								    <div class="form-group">
								      <label for="exampleInputPassword1">公益类型描述</label>
								      <input type="text" class="form-control" id="gType" placeholder="公益类型描述">
								    </div>
			
								    
								  </form>
						  
								
								
						      </div>
						      <div class="modal-footer">
						        <button type="button" class="btn btn-default" data-dismiss="modal">Close</button>
						        <button type="button" class="btn btn-primary" onclick="addg()">创建</button>
						      </div>
						    </div>
						  </div>
						</div>
						<div class="panel-heading">
							<div class="panel-title">
								项目分类列表
								<button class="btn btn-default" data-toggle="modal" data-target="#myModal5" type="button" >添加</button>
							</div>
						</div>
						<div class="panel-body">
							<div class="table-responsive ">
								<table class="table table-striped table-bordered">
									<thead>
										<tr>
											<th>公益类型名字</th>
											<th>公益类型描述</th>
											<th>公益类型创建时间</th>
											<th>操作</th>
										</tr>
									</thead>
									<tbody id="xiangMuFenLei_msg">
									</tbody>
								</table>
							</div>
							
						</div>
					</div>
					<div id="xiangMuTuiJian" class="panel panel-default tab-pane">
						<div class="modal fade" id="myModal3" tabindex="-1" role="dialog" aria-labelledby="myModalLabel">
						  <div class="modal-dialog" role="document">
						    <div class="modal-content">
						      <div class="modal-header">
						        <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>
						        <h4 class="modal-title" id="myModalLabel">请选择上架时间</h4>
						      </div>
						      <div class="modal-body">
								  <p id="psDay1"></p>
								  请输入上架时间
						        <input type="date" name="" id="shajiadate" value="" onblur="jiaoyanshijian()"/>
								<br>
								项目结束时间为
								<p id="endtime"></p>
						      </div>
						      <div class="modal-footer">
						        <button type="button" class="btn btn-default" data-dismiss="modal">Close</button>
						        <button type="button" id="mo3but" psId="" class="btn btn-primary" onclick="baocunshijian()">Save changes</button>
						      </div>
						    </div>
						  </div>
						</div>
						<div class="panel-heading">
							<div class="panel-title">
								项目推荐列表
							</div>
						</div>
						<div class="panel-body">
							<div class="table-responsive ">
								<table class="table table-striped table-bordered">
									<thead>
										<tr>
											<th>序号</th>
											<th>项目类型</th>
											<th>项目名称</th>
											<!-- <th>项目进度</th> -->
											<th>筹集时间</th>
											<th>已筹金额</th>
											<th>发起人</th>
											<th>操作</th>
										</tr>
									</thead>
									<tbody id="xiangMuTuiJian_msg">
									</tbody>
								</table>
							</div>
							<nav aria-label="Page navigation" class="text-right">
								<ul class="pagination" id="showPage_xiangMuTuiJian">
								</ul>
							</nav>
						</div>
					</div>
				</div>
			</div>
		</div>

		<script type="text/javascript" src="${pageContext.request.contextPath}/admin/js/jquery1.12.4.min.js"></script>
		<script type="text/javascript" src="${pageContext.request.contextPath}/admin/js/bootstrap.min.js"></script>
		<script type="text/javascript" src="${pageContext.request.contextPath}/admin/js/countUp.js"></script>
		<script>
			$(document).ready(function() {
				ajaxPage(1)
				$('a[href="#suo_you_xiang_mu"]').click(function() {
					$("#products>li").removeClass("active");
					$("#products1>div").removeClass("active");
					$('a[href="#suo_you_xiang_mu"]').parent().addClass("active");
					$("#suo_you_xiang_mu").addClass("active");
					$("#chaxunxianshi").css('display', 'block');
					emps(1)
				})
				$('a[href="#xiangMuShenHe"]').click(function() {
					$("#products>li").removeClass("active");
					$("#products1>div").removeClass("active");
					$('a[href="#xiangMuShenHe"]').parent().addClass("active");
					$("#xiangMuShenHe").addClass("active");
					$("#chaxunxianshi").css('display', 'none');
					xianfmushenhe(1);
				})
				$('a[href="#xiangMuPingLun"]').click(function() {
					$("#products>li").removeClass("active");
					$("#products1>div").removeClass("active");
					$('a[href="#xiangMuPingLun"]').parent().addClass("active");
					$("#xiangMuPingLun").addClass("active");
					$("#chaxunxianshi").css('display', 'none');
					suoyoupinglun(1);
				})
				$('a[href="#xiangMuFenLei"]').click(function() {
					$("#products>li").removeClass("active");
					$("#products1>div").removeClass("active");
					$('a[href="#xiangMuFenLei"]').parent().addClass("active");
					$("#xiangMuFenLei").addClass("active");
					$("#chaxunxianshi").css('display', 'none');
					gongyileixing(1)
				})
				$('a[href="#xiangMuTuiJian"]').click(function() {
					$("#products>li").removeClass("active");
					$("#products1>div").removeClass("active");
					$('a[href="#xiangMuTuiJian"]').parent().addClass("active");
					$("#xiangMuTuiJian").addClass("active");
					$("#chaxunxianshi").css('display', 'none');
					tuijianjiangmu(1)
				})
			});
/* 得到所有项目列表 */
			function ajaxPage(page) {
				$.ajax({
					url: "getProjectsByPsName",
					dataType: "JSON",
					type: "get",
					data: {
						pn: page
					},
					success: function(result) {
						//console.log(result);
						var pageInfo = result.extend["pageInfo"]
						var msg = ""
						$.each(pageInfo.list, function(i, item) {

							msg += "<tr>" +
								"<td>" + (parseInt(pageInfo.pageNum - 1) * 5 + 1 + i) + "</td>" +
								"<td>" + item.projectsType.pstName + "</td>" +
								"<td>" + item.psName + "</td>" +
								"<td>" + item.psStarttime + "</td>" +
								"<td>" + item.psEndtime + "</td>" +
								"<td>" + item.psGetmoney + "</td>" +
								"<td>" + item.users.usName + "</td>" +
								"<td>" +
								"<a href='toBackProductInfo?psId=" + item.psId + "'>详情</a>" +
								"</td>" +
								"</tr>"
						})
						$("#projectslist").html(msg)
						var msg = build_page_nav(pageInfo);
						$("#showPage").html(msg);
					},
					error: function(err) {}
				})
			}
/* 分页查项列表 */
			function emps(pageNum) {
				event.stopPropagation();
				console.log(pageNum)
				ajaxPage(pageNum)
			}
/* 页码1 */
			function build_page_nav(pageInfo2) {
				//上一页
				var previous2 = ""
				if (pageInfo2.hasPreviousPage) {
					previous2 = previous2 + "<li><span onclick='emps(" +
						(parseInt(pageInfo2.pageNum) - parseInt(1)) + ")' aria-label='Previous'>" +
						"<span aria-hidden='true'>&laquo;</span>" +
						"</span></li>"
				}
				//下一页
				var next2 = ""
				if (pageInfo2.hasNextPage) {
					next2 = next2 + "<li><span onclick='emps(" +
						(parseInt(pageInfo2.pageNum) + parseInt(1)) +
						")' aria-label='Next'>" +
						"<span aria-hidden='true'>&raquo;</span>" +
						"</span></li>"
				}
				//页数
				var pageNum2 = ""
				$.each(pageInfo2.navigatepageNums, function(i, item) {

					if (item == pageInfo2.pageNum) {
						pageNum2 += "<li class='active'><span>" + item + "</span></li>"
					} else {
						pageNum2 += "<li><span class='emps' onclick='emps(" + item +
							")'>" + item + "</span></li>"
					}


				})
				var msg = ""
				/* msg += "<div class='col-md-6'>" + "当前第" + pageInfo2.pageNum +
					"页，总共" + pageInfo2.pages + "页，共" + pageInfo2.total +
					"条记录</div>" + "<div class='col-md-6'>" +
					"<nav aria-label='Page navigation'>" +
					"<ul class='pagination'>" + "<li><span onclick='emps(" +
					pageInfo2.navigateFirstPage + ")'>首页</span></li>" +
					previous2 + pageNum2 + next2 + "<li><span onclick='emps(" +
					pageInfo2.navigateLastPage + ")'>末页</span></li>" +
					"</ul>" + "</nav>" + "</div>" */
				msg += "<li><span onclick='emps(" +
					pageInfo2.navigateFirstPage + ")'>首页</span></li>" +
					previous2 + pageNum2 + next2 + "<li><span onclick='emps(" +
					pageInfo2.navigateLastPage + ")'>末页</span></li>"
				return msg
			}
/* 项目待审核列表 */
			function xianfmushenhe(page) {
				$.ajax({
					url: "getAllProjectAndType",
					dataType: "JSON",
					type: "get",
					data: {
						"page": page,
						"psType": 0
						
					},
					success: function(result) {
						//console.log(result);
						var pageInfo = result.extend["pageInfo"]
						var msg = ""
						$.each(pageInfo.list, function(i, item) {

							msg += "<tr>" +
								"<td>" + (parseInt(pageInfo.pageNum - 1) * 5 + 1 + i) + "</td>" +
								"<td>" + item.projectsType.pstName + "</td>" +
								"<td>" + item.psName + "</td>" +
								"<td>" + item.psMoney + "</td>" +
								"<td>" + item.psGoal + "</td>" +
								"<td>" + item.psDays + "</td>" +
								"<td>" + item.users.usName + "</td>" +
								"<td>" +
								"<a href='toBackProductInfo?psId=" + item.psId + "'>详情</a>" +
								"<button onclick='bangding(" + item.psId +
								")' type='button' aria-hidden='true' class='btn btn-success btn-lg' data-toggle='modal' data-target='#myModal'>审核通过</button>" +

								"<button onclick='bangding(" + item.psId +
								")' type='button' aria-hidden='true' class='btn btn-danger btn-lg' data-toggle='modal' data-target='#myModal1'>审核不通过</button>" +
								"</td>" +
								"</tr>"
						})
						$("#xiangmushenhe_msg").html(msg)
						var msg = build_page_nav2(pageInfo);
						$("#showPage_shenhe").html(msg)
					},
					error: function(err) {}
				})
			}
/* 分页2 */
			function build_page_nav2(pageInfo2) {
				//上一页
				var previous2 = ""
				if (pageInfo2.hasPreviousPage) {
					previous2 = previous2 + "<li><span onclick='xianfmushenhe(" +
						(parseInt(pageInfo2.pageNum) - parseInt(1)) + ")' aria-label='Previous'>" +
						"<span aria-hidden='true'>&laquo;</span>" +
						"</span></li>"
				}
				//下一页
				var next2 = ""
				if (pageInfo2.hasNextPage) {
					next2 = next2 + "<li><span onclick='xianfmushenhe(" +
						(parseInt(pageInfo2.pageNum) + parseInt(1)) +
						")' aria-label='Next'>" +
						"<span aria-hidden='true'>&raquo;</span>" +
						"</span></li>"
				}
				//页数
				var pageNum2 = ""
				$.each(pageInfo2.navigatepageNums, function(i, item) {

					if (item == pageInfo2.pageNum) {
						pageNum2 += "<li class='active'><span>" + item + "</span></li>"
					} else {
						pageNum2 += "<li><span class='emps' onclick='xianfmushenhe(" + item +
							")'>" + item + "</span></li>"
					}


				})
				var msg = ""
				/* msg += "<div class='col-md-6'>" + "当前第" + pageInfo2.pageNum +
					"页，总共" + pageInfo2.pages + "页，共" + pageInfo2.total +
					"条记录</div>" + "<div class='col-md-6'>" +
					"<nav aria-label='Page navigation'>" +
					"<ul class='pagination'>" + "<li><span onclick='emps(" +
					pageInfo2.navigateFirstPage + ")'>首页</span></li>" +
					previous2 + pageNum2 + next2 + "<li><span onclick='emps(" +
					pageInfo2.navigateLastPage + ")'>末页</span></li>" +
					"</ul>" + "</nav>" + "</div>" */
				msg += "<li><span onclick='xianfmushenhe(" +
					pageInfo2.navigateFirstPage + ")'>首页</span></li>" +
					previous2 + pageNum2 + next2 + "<li><span onclick='xianfmushenhe(" +
					pageInfo2.navigateLastPage + ")'>末页</span></li>"
				return msg
			}
/* 审核模态框 */
			function bangding(psId) {
				$("#btu_Yes").attr("psId", psId)
				$("#btu_No").attr("psId", psId)
				var psId = $("#btu_Yes").attr("psId")
				$("#btu_Yes").on("click", function() {
					projectSuccessful(psId)
				})
				$("#btu_No").on("click", function() {
					projectFailure(psId)
				})
			}
/* 审核成功 */
			function projectSuccessful(psId) {
				$.ajax({
					url: "projectSuccessful",
					dataType: "JSON",
					type: "get",
					data: {
						"psId": psId
					},
					success: function(result) {
						if (result.code == 200) {
							alert("审核成功")
							$('#myModal').modal('hide');
							xianfmushenhe(1)
						}
					},
					error: function(err) {}
				})
			}
/* 审核不成功 */
			function projectFailure(psId) {
				$.ajax({
					url: "projectFailure",
					dataType: "JSON",
					type: "get",
					data: {
						"psId": psId
					},
					success: function(result) {
						if (result.code == 200) {
							alert("审核成功")
							$('#myModal1').modal('hide');
							xianfmushenhe(1)
						}
					},
					error: function(err) {}
				})
			}
			/* 所有评论分页 */
			function suoyoupinglun(pageNum){
				$.ajax({
					url: "getAllComments",
					dataType: "JSON",
					type: "get",
					data: {
						"page": pageNum		
					},
					success: function(result) {
						//console.log(result);
						var pageInfo = result.extend["pageInfo"]
						var msg = ""
						$.each(pageInfo.list,function(i,item){
							msg+="<tr>"+
								"<th>"+item.cmContent+"</th>"+
								"<th>"+item.users.usName+"</th>"+
								"<th>"+item.cmTime+"</th>"+
								"<th onclick='deleteComById("+item.cmId+")'>删除</th>"+
								"</tr>"	
						})
						
						$("#xiangMuPingLun_msg").html(msg)
						
						msg = build_page_nav3(pageInfo);
						
						$("#showPage_xiangMuPingLun1").html(msg)
					},
					error: function(err) {}
				})
			}
			/* 删除评论 */
			function deleteComById(cmId){
				if(confirm("你确定要删除吗")){
					$.ajax({
						url: "deleteCommentsById",
						dataType: "JSON",
						type: "get",
						data: {
							"cmId": cmId		
						},
						success: function(result) {
							if(result.code==200){
								alert("删除成功")
								suoyoupinglun(1);
							}
							
						},
						error: function(err) {}
					})
					
				}
				
				
			}
			/* 所有评论分页 */
			function build_page_nav3(pageInfo2){
				//上一页
				var previous2 = ""
				if (pageInfo2.hasPreviousPage) {
					previous2 = previous2 + "<li><span onclick='suoyoupinglun(" +
						(parseInt(pageInfo2.pageNum) - parseInt(1)) + ")' aria-label='Previous'>" +
						"<span aria-hidden='true'>&laquo;</span>" +
						"</span></li>"
				}
				//下一页
				var next2 = ""
				if (pageInfo2.hasNextPage) {
					next2 = next2 + "<li><span onclick='suoyoupinglun(" +
						(parseInt(pageInfo2.pageNum) + parseInt(1)) +
						")' aria-label='Next'>" +
						"<span aria-hidden='true'>&raquo;</span>" +
						"</span></li>"
				}
				//页数
				var pageNum2 = ""
				$.each(pageInfo2.navigatepageNums, function(i, item) {
				
					if (item == pageInfo2.pageNum) {
						pageNum2 += "<li class='active'><span>" + item + "</span></li>"
					} else {
						pageNum2 += "<li><span class='emps' onclick='suoyoupinglun(" + item +
							")'>" + item + "</span></li>"
					}
				
				
				})
				var msg = ""
				/* msg += "<div class='col-md-6'>" + "当前第" + pageInfo2.pageNum +
					"页，总共" + pageInfo2.pages + "页，共" + pageInfo2.total +
					"条记录</div>" + "<div class='col-md-6'>" +
					"<nav aria-label='Page navigation'>" +
					"<ul class='pagination'>" + "<li><span onclick='emps(" +
					pageInfo2.navigateFirstPage + ")'>首页</span></li>" +
					previous2 + pageNum2 + next2 + "<li><span onclick='emps(" +
					pageInfo2.navigateLastPage + ")'>末页</span></li>" +
					"</ul>" + "</nav>" + "</div>" */
				msg += "<li><span onclick='suoyoupinglun(" +
					pageInfo2.navigateFirstPage + ")'>首页</span></li>" +
					previous2 + pageNum2 + next2 + "<li><span onclick='suoyoupinglun(" +
					pageInfo2.navigateLastPage + ")'>末页</span></li>"
				return msg
			}
			/* 公益类型 */
			function gongyileixing(pageNum){
				$.ajax({
					url: "getAllClass",
					dataType: "JSON",
					type: "get",
					data: {
						"page": pageNum		
					},
					success: function(result) {
						//console.log(result);
						var list = result.extend["list"]
						var msg = ""
						$.each(list,function(i,item){
							msg+="<tr>"+
								"<th>"+item.pstName+"</th>"+
								"<th>"+item.pstDesc+"</th>"+
								"<th>"+item.pstStardate+"</th>"+
								"<th onclick='deleteClassById("+item.pstId+")'>删除</th>"+
								"</tr>"	
						})
						
						$("#xiangMuFenLei_msg").html(msg)
					},
					error: function(err) {}
				})
			}
			/* 删除类型 */
			function deleteClassById(pstId){
				if(confirm("确定要删除吗")){
					$.ajax({
						url: "deleteClassById",
						dataType: "JSON",
						type: "get",
						data: {
							"pstId": pstId		
						},
						success: function(result) {
							//console.log(result);
							if(result.code==200){
								alert("删除成功")
								//window.location.reload();
								gongyileixing(1)
							}
						},
						error: function(err) {}
					})
				}
				
			}
			/* 推荐项目 */
			function tuijianjiangmu(pageNum){
				$.ajax({
					url: "getAllProjectAndType",
					dataType: "JSON",
					type: "get",
					data: {
						"psType": 1		
					},
					success: function(result) {
						//console.log(result);
						var pageInfo = result.extend["pageInfo"]
						var msg = ""
						$.each(pageInfo.list, function(i, item) {
						
							msg += "<tr>" +
								"<td>" + (parseInt(pageInfo.pageNum - 1) * 5 + 1 + i) + "</td>" +
								"<td>" + item.projectsType.pstName + "</td>" +
								"<td>" + item.psName + "</td>" +
								"<td>" + item.psDays + "</td>" +
								"<td>" + item.psGetmoney + "</td>" +
								"<td>" + item.users.usName + "</td>" +
								"<td>" +
								"<a data-toggle='modal' data-target='#myModal3' onclick='shangjia1("+item.psId+")'>上架</a>" +
								"</td>" +
								"</tr>"
						})
						
						$("#xiangMuTuiJian_msg").html(msg)
						
						msg = build_page_nav4(pageInfo);
						
						$("#showPage_xiangMuTuiJian").html(msg)
					},
					error: function(err) {}
				})
			}
		/* 	分页 */
			function build_page_nav4(pageInfo2){
				//上一页
				var previous2 = ""
				if (pageInfo2.hasPreviousPage) {
					previous2 = previous2 + "<li><span onclick='tuijianjiangmu(" +
						(parseInt(pageInfo2.pageNum) - parseInt(1)) + ")' aria-label='Previous'>" +
						"<span aria-hidden='true'>&laquo;</span>" +
						"</span></li>"
				}
				//下一页
				var next2 = ""
				if (pageInfo2.hasNextPage) {
					next2 = next2 + "<li><span onclick='tuijianjiangmu(" +
						(parseInt(pageInfo2.pageNum) + parseInt(1)) +
						")' aria-label='Next'>" +
						"<span aria-hidden='true'>&raquo;</span>" +
						"</span></li>"
				}
				//页数
				var pageNum2 = ""
				$.each(pageInfo2.navigatepageNums, function(i, item) {
				
					if (item == pageInfo2.pageNum) {
						pageNum2 += "<li class='active'><span>" + item + "</span></li>"
					} else {
						pageNum2 += "<li><span class='emps' onclick='tuijianjiangmu(" + item +
							")'>" + item + "</span></li>"
					}
				
				
				})
				var msg = ""
				/* msg += "<div class='col-md-6'>" + "当前第" + pageInfo2.pageNum +
					"页，总共" + pageInfo2.pages + "页，共" + pageInfo2.total +
					"条记录</div>" + "<div class='col-md-6'>" +
					"<nav aria-label='Page navigation'>" +
					"<ul class='pagination'>" + "<li><span onclick='emps(" +
					pageInfo2.navigateFirstPage + ")'>首页</span></li>" +
					previous2 + pageNum2 + next2 + "<li><span onclick='emps(" +
					pageInfo2.navigateLastPage + ")'>末页</span></li>" +
					"</ul>" + "</nav>" + "</div>" */
				msg += "<li><span onclick='tuijianjiangmu(" +
					pageInfo2.navigateFirstPage + ")'>首页</span></li>" +
					previous2 + pageNum2 + next2 + "<li><span onclick='tuijianjiangmu(" +
					pageInfo2.navigateLastPage + ")'>末页</span></li>"
				return msg
			}
			/* 上架 */
			function shangjia1(psId){
				$("#mo3but").attr("psId",psId)
				$("#endtime").html("")
				$("#shajiadate").val("")
				$.ajax({
					url: "getProjectsById",
					dataType: "JSON",
					type: "get",
					data: {
						"psId": psId		
					},
					success: function(result) {
						var projects = result.extend["projects"]
						var psDays = projects.psDays
						$("#psDay1").html("该项目的筹集时间为"+psDays+"天")
						$("#psDay1").attr("psDays",psDays)
					},
					error: function(err) {}
				})
			}
			function jiaoyanshijian(){
				var da = new Date()
				var da2=da.getFullYear()+"-"+(da.getMonth()+1)+"-"+da.getDate();
				if($("#shajiadate").val()==""){
					$("#endtime").html("")
				}
				//alert(da2)
				var d= new Date($("#shajiadate").val());//这里日期是传递过来的，可以自己改
				
				var psDays = $("#psDay1").html()					
				d.setDate(d.getDate() + parseInt($("#psDay1").attr("psDays")));//天数+1			
				var d2=d.getFullYear()+"-"+(d.getMonth()+1)+"-"+d.getDate();
				
				$("#endtime").html(d2)
			}
			function baocunshijian(){
				$.ajax({
					url: "onTheProjectById",
					dataType: "JSON",
					type: "get",
					data: {
						"psId": $("#mo3but").attr("psId"),
						"psStarttime":$("#shajiadate").val(),
						"psEndtime":$("#endtime").html()
					},
					success: function(result) {
						if(result.code==200){
							alert("上架成功")
							$('#myModal3').modal('hide');
							tuijianjiangmu(1)
						}
					},
					error: function(err) {}
				})
			}
			/* 添加类型 */
			function addg(){
				var da = new Date()
				var da2=da.getFullYear()+"-"+(da.getMonth()+1)+"-"+da.getDate();
				$.ajax({
					url: "addClass",
					dataType: "JSON",
					type: "get",
					data: {
						"pstName": $("#gName").val(),
						"pstDesc":$("#gType").val(),
						"pstStardate":da2
					},
					success: function(result) {
						if(result.code==200){
							$('#myModal5').modal('hide');
							alert("添加成功")
							tuijianjiangmu(1)
						}
					},
					error: function(err) {}
				})
			}
			function tiaojianchapro1(page){
				
				$.ajax({
					url: "getAllProjectAndType",
					dataType: "JSON",
					type: "get",
					data: {
						"page": page,
						"psName":$("#exampleInputName22").val(),
						"usName":$("#exampleInputName23").val(),
						"psType":$("#exampleInputName24").val(),
						"pstId":$("#exampleInputName25").val(),
					},
					success: function(result) {
					
						//console.log(result);
						var pageInfo = result.extend["pageInfo"]
						var msg = ""
						//alert(pageInfo.list)
						$.each(pageInfo.list, function(i, item) {
							
							msg += "<tr>" +
								"<td>" + (parseInt(pageInfo.pageNum - 1) * 5 + 1 + i) + "</td>" +
								"<td>" + item.projectsType.pstName + "</td>" +
								"<td>" + item.psName + "</td>" +
								"<td>" + item.psStarttime + "</td>" +
								"<td>" + item.psEndtime + "</td>" +
								"<td>" + item.psGetmoney + "</td>" +
								"<td>" + item.users.usName + "</td>" +
								"<td>" +
								"<a href='toBackProductInfo?psId=" + item.psId + "'>详情</a>" +
								"</td>" +
								"</tr>"
						})
						$("#projectslist").html(msg)
						var msg = build_page_nav7(pageInfo);
						$("#showPage").html(msg);
					},
					error: function(err) {}
				})
			}
	
					function build_page_nav7(pageInfo2) {
							//上一页
							var previous2 = ""
							if (pageInfo2.hasPreviousPage) {
								previous2 = previous2 + "<li><span onclick='tiaojianchapro1(" +
									(parseInt(pageInfo2.pageNum) - parseInt(1)) + ")' aria-label='Previous'>" +
									"<span aria-hidden='true'>&laquo;</span>" +
									"</span></li>"
							}
							//下一页
							var next2 = ""
							if (pageInfo2.hasNextPage) {
								next2 = next2 + "<li><span onclick='tiaojianchapro1(" +
									(parseInt(pageInfo2.pageNum) + parseInt(1)) +
									")' aria-label='Next'>" +
									"<span aria-hidden='true'>&raquo;</span>" +
									"</span></li>"
							}
							//页数
							var pageNum2 = ""
							$.each(pageInfo2.navigatepageNums, function(i, item) {
			
								if (item == pageInfo2.pageNum) {
									pageNum2 += "<li class='active'><span>" + item + "</span></li>"
								} else {
									pageNum2 += "<li><span class='emps' onclick='tiaojianchapro1(" + item +
										")'>" + item + "</span></li>"
								}
			
			
							})
							var msg = ""
							/* msg += "<div class='col-md-6'>" + "当前第" + pageInfo2.pageNum +
								"页，总共" + pageInfo2.pages + "页，共" + pageInfo2.total +
								"条记录</div>" + "<div class='col-md-6'>" +
								"<nav aria-label='Page navigation'>" +
								"<ul class='pagination'>" + "<li><span onclick='emps(" +
								pageInfo2.navigateFirstPage + ")'>首页</span></li>" +
								previous2 + pageNum2 + next2 + "<li><span onclick='emps(" +
								pageInfo2.navigateLastPage + ")'>末页</span></li>" +
								"</ul>" + "</nav>" + "</div>" */
							msg += "<li><span onclick='tiaojianchapro1(" +
								pageInfo2.navigateFirstPage + ")'>首页</span></li>" +
								previous2 + pageNum2 + next2 + "<li><span onclick='tiaojianchapro1(" +
								pageInfo2.navigateLastPage + ")'>末页</span></li>"
							return msg
						}

		</script>
	</body>
</html>
